// xutility experimental header
#pragma once
#ifndef _EXPERIMENTAL_XUTILITY_
#define _EXPERIMENTAL_XUTILITY_
#ifndef RC_INVOKED

#include <xutility>
#include <algorithm>

 #pragma pack(push,_CRT_PACKING)
 #pragma warning(push,_STL_WARNING_LEVEL)
 #pragma warning(disable: _STL_DISABLED_WARNINGS)
 #pragma push_macro("new")
 #undef new

_STD_BEGIN
namespace experimental {
	inline namespace fundamentals_v2 {

	// TEMPLATE FUNCTION _Erase_nodes_if
template<class _Container,
	class _Pr> inline
	void _Erase_nodes_if(_Container& _Cont, _Pr& _Pred)
	{	// erase each element satisfying _Pred
	auto _First = _Cont.begin();
	auto _Last = _Cont.end();
	while (_First != _Last)
		if (_Pred(*_First))
			_First = _Cont.erase(_First);
		else
			++_First;
	}


	// TEMPLATE FUNCTION _Erase_remove_if
template<class _Container,
	class _Pr> inline
	void _Erase_remove_if(_Container& _Cont, _Pr& _Pred)
	{	// erase each element satisfying _Pred
	auto _First = _Cont.begin();
	auto _Last = _Cont.end();
	_Cont.erase(_Rechecked(_First,
		_Remove_if_unchecked(_Unchecked(_First), _Unchecked(_Last), _Pred)), _Last);
	}

	// TEMPLATE FUNCTION _Erase_remove
template<class _Container,
	class _Uty> inline
	void _Erase_remove(_Container& _Cont, const _Uty& _Val)
	{	// erase each element matching _Val
	auto _First = _Cont.begin();
	auto _Last = _Cont.end();
	_Cont.erase(_Rechecked(_First,
		_Remove_unchecked(_Unchecked(_First), _Unchecked(_Last), _Val)), _Last);
	}

	}	// inline namespace fundamentals_v2
}	// namespace experimental
_STD_END

 #pragma pop_macro("new")
 #pragma warning(pop)
 #pragma pack(pop)

#endif /* RC_INVOKED */
#endif /* _EXPERIMENTAL_XUTILITY_ */

/*
 * Copyright (c) by P.J. Plauger. All rights reserved.
 * Consult your license regarding permissions and restrictions.
V6.50:0009 */
